import request from "@/utils/request";
import { ArticleQuery, ArticlePageResult, ArticleForm } from "./model";

/**
 * 文章API
 */
class ArticleAPI {
  /**
   * 获取文章分页数据
   *
   * @param queryParams
   */
  static getPage(queryParams?: ArticleQuery) {
    return request<any, ArticlePageResult>({
      url:
        "/article/getPage?currentPage=" +
        queryParams?.pageNum +
        "&size=" +
        queryParams?.pageSize,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 新增文章
   *
   * @param data
   */
  static add(data: ArticleForm) {
    return request({
      url: "/article/add",
      method: "post",
      data: data,
    });
  }
  /**
   * 修改文章
   * @param data 
   * @returns 
   */
  static update(data: ArticleForm) {
    return request({
      url: "/article/edit",
      method: "post",
      data: data,
    });
  }

  /**
   * 删除文章
   * @param data 
   * @returns 
   */
  static delete(data: ArticleForm) {
    return request({
      url: "/article/delete",
      method: "post",
      data: data,
    });
  }


  /**
   * 获取未关联的图片分页数据
   * @param queryParams 
   * @returns 
   */
  static getPageNoRelative(queryParams?: ArticleQuery) {
    return request<any, ArticlePageResult>({
      url:
        "/article/getPageNoRelative?currentPage=" +
        queryParams?.pageNum +
        "&size=" +
        queryParams?.pageSize,
      method: "post",
      data: queryParams,
    });
  }
  /**
   * 获取已关联的图片分页数据
   * @param queryParams 
   * @returns 
   */
  static getPageRelative(queryParams?: ArticleQuery) {
    return request<any, ArticlePageResult>({
      url:
        "/article/getPageRelative?currentPage=" +
        queryParams?.pageNum +
        "&size=" +
        queryParams?.pageSize,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 获取未关联的图片分页数据
   * @param queryParams 
   * @returns 
   */
  static getPageNoRelativeFull(queryParams?: ArticleQuery) {
    return request<any, ArticlePageResult>({
      url:
        "/article/getPageNoRelativeFull?currentPage=" +
        queryParams?.pageNum +
        "&size=" +
        queryParams?.pageSize,
      method: "post",
      data: queryParams,
    });
  }

  /**
   * 获取已关联的图片分页数据
   * @param queryParams 
   * @returns 
   */
  static getPageRelativeFull(queryParams?: ArticleQuery) {
    return request<any, ArticlePageResult>({
      url:
        "/article/getPageRelativeFull?currentPage=" +
        queryParams?.pageNum +
        "&size=" +
        queryParams?.pageSize,
      method: "post",
      data: queryParams,
    });
  }


  /**
   * 添加到图片关联表
   * @param data 
   * @returns 
   */
  static addToRelative(data: ArticleForm) {
    return request({
      url: "/article/addToRelative",
      method: "post",
      data: data,
    });
  }


  /**
   * 删除模块图片
   * @param data 
   * @returns 
   */

  static removeArticleRelative(data: ArticleForm) {
    return request({
      url: "/article/removeArticleRelative",
      method: "post",
      data: data,
    });
  }





}

export default ArticleAPI;
